/*
 * config_clock.h
 *
 *  Created on: Aug 12, 2013
 *      Author: Ken Arok
 */

#include "config_board.h"

#if BOARD_1_0_USED

#ifndef CONFIG_CLOCK_H_
#define CONFIG_CLOCK_H_


//#define CONFIG_SYSCLK_SOURCE          SYSCLK_SRC_RCSYS
//#define CONFIG_SYSCLK_SOURCE        SYSCLK_SRC_OSC0
#define CONFIG_SYSCLK_SOURCE        SYSCLK_SRC_PLL0
//#define CONFIG_SYSCLK_SOURCE        SYSCLK_SRC_PLL1
//#define CONFIG_SYSCLK_SOURCE        SYSCLK_SRC_RC8M
//#define CONFIG_SYSCLK_SOURCE		SYSCLK_SRC_RC120M





#define CONFIG_PLL0_SOURCE            PLL_SRC_OSC0
//#define CONFIG_PLL0_SOURCE          PLL_SRC_RC8M

/* Fpll0 = (Fclk * PLL_mul) / PLL_div */
#define CONFIG_PLL0_MUL               (FSYS0_HZ / BOARD_OSC0_HZ)
#define CONFIG_PLL0_DIV               (1)

#define CONFIG_PLL1_SOURCE          PLL_SRC_OSC0
//#define CONFIG_PLL1_SOURCE          PLL_SRC_RC8M

/* Fpll1 = (Fclk * PLL_mul) / PLL_div */
#define CONFIG_PLL1_MUL               (FSYS1_HZ / BOARD_OSC0_HZ)
#define CONFIG_PLL1_DIV               (1)

/* ====== System Clock Bus Division Options ====== */
#define CONFIG_SYSCLK_CPU_DIV         (1)	//! Fcpu = Fsys/(2 ^ CPU_div)
#define CONFIG_SYSCLK_PBA_DIV         (2)	//! Fpba = Fsys/(2 ^ PBA_div)
#define CONFIG_SYSCLK_PBB_DIV         (2)	//! Fpbb = Fsys/(2 ^ PBB_div)
#define CONFIG_SYSCLK_PBC_DIV         (2)	//! Fpbc = Fsys/(2 ^ PBC_div)

/* ====== Peripheral Clock Management Options ====== */
#define CONFIG_SYSCLK_INIT_PBAMASK		((1 << SYSCLK_FREQM) | (1 << SYSCLK_TWIM1) | (1 << SYSCLK_TWIS0) | (1 << SYSCLK_TWIS1) |		\
										(1 << SYSCLK_IISC) | (1 << SYSCLK_PWM) | (1 << SYSCLK_QDEC0) | (1 << SYSCLK_QDEC1) |			\
										(1 << SYSCLK_ACIFA0) | (1 << SYSCLK_ACIFA1) | (1 << SYSCLK_DACIFB0) | (1 << SYSCLK_DACIFB1) |	\
										(1 << SYSCLK_USART0))
#define CONFIG_SYSCLK_INIT_PBBMASK		((1 << SYSCLK_SAU_REGS) |(1 << SYSCLK_SMC_REGS))
#define CONFIG_SYSCLK_INIT_PBCMASK		((1 << SYSCLK_PDCA_PB) | (1 << SYSCLK_MDMA_REGS) | (1 << SYSCLK_CANIF_REGS) | (1 << SYSCLK_TWIM2) |	\
										(1 << SYSCLK_TWIS2))
#define CONFIG_SYSCLK_INIT_HSBMASK		((1 << SYSCLK_SAU_HSB) | (1 << SYSCLK_PDCA_HSB) | (1 << SYSCLK_MDMA_HSB) | (1 << SYSCLK_CANIF_DATA) |	\
										(1 << SYSCLK_PEVC_HSB))

/* ====== USB Clock Source Option ======= */
//#define CONFIG_USBCLK_SOURCE			USBCLK_SRC_OSC0
//#define   CONFIG_USBCLK_SOURCE		USBCLK_SRC_PLL0
#define CONFIG_USBCLK_SOURCE			USBCLK_SRC_PLL1
#define CONFIG_USBCLK_DIV				1 //! Fusb = Fsys / USB_div


#endif /* CONFIG_CLOCK_H_ */

#endif /* BOARD_1_0_USED */
